﻿#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
//常用查找算法count

//1.统计内置数据类型
void test01()
{
	vector<int>v;
	v.push_back(10);
	v.push_back(40);
	v.push_back(30);
	v.push_back(40);
	v.push_back(20);
	v.push_back(40);
	int num1=count(v.begin(), v.end(), 40);
	cout << num1 << endl;
}
//2.统计自定义数据类型
class Person
{
public:
	Person(string name, int age)
	{
		this->m_Age = age;
		this->m_Name = name;
	}
	bool operator==(const Person& p)
	{
		if (this->m_Age=p.m_Age)
			return true;
		else
			return false;
	}
	int m_Age;
	string m_Name;
};
void test02()
{
	Person p1("AA", 20);
	Person p2("BB", 30);
	Person p3("CC", 30);
	Person p4("DD", 20);
	Person p5("EE", 25);
	vector<Person>v;
	v.push_back(p1);
	v.push_back(p2);
	v.push_back(p3);
	v.push_back(p4);
	v.push_back(p5);
	int num2 = count(v.begin(), v.end(), p2);
	cout << num2 << endl;
}
int main()
{
	test01();
	test02();
}